classdef dotsDrawableLines < dotsDrawable
    % @class dotsDrawableLines
    % Draw one or multiple lines at once.
    %
    % @ingroup drawable
    
    properties (SetObservable = true)
        % a pair of x-coordinates per line (degrees visual angle, centered)
        x = [0 0];
        
        % a pair of y-coordinates per line (degrees visual angle, centered)
        y = [1 1];
        
        % one width for all lines, or a width for each line (pixels)
        width = 1;
        
        % one color for all lines, or a color for each end of each line.
        % Different end colors will get blended across the length of the
        % line (3xn or 4xn array.  n may be 1 or the length of x and y.  3
        % rows must specify RGB color components from 0-255.  A fourth row
        % may specify a transparency component, also 0-255)
        color = [255 255 255];
        
        % whether to do anti-aliasing for diagonal lines (true/false)
        smooth = false;
    end
    
    methods
        % Constructor takes no arguments.
        function self = dotsDrawableLines
            self = self@dotsDrawable;
            self.color = self.foregroundColor;
        end
        
        % Draw one or more lines at once.
        function draw(self)
            if length(self.x) > 1
                Screen('DrawLines', ...
                    self.windowNumber, ...
                    cat(1, self.x, -self.y)*self.pixelsPerDegree, ...
                    self.width, ...
                    self.color, ...
                    (self.windowRect(3:4) - self.windowRect(1:2))./2, ...
                    double(self.smooth));
            end
        end
    end
end